import { NavigationActions, StackActions } from 'react-navigation';
import { NAVIGATIONS, GLOBAL } from '../../../../config/global';
import navigationSeevice from '../../../../components/navigation/navigationSeevice';

class OrderCreactService {

  CURRENCY_ENUM = [{
    dictKey: 'RMB',
    dictName: '人民币',
  }, {
    dictKey: 'USD',
    dictName: '美元',
  }]

  jump (page, params, cb) {
    this.props.navigation.navigate(page, {
      ...params,
      callBack: cb,
    });
  }

  reset (orderType, tCode, status) {
    // typeIndex 0，1，2（销售成交，采购成交，新油)
    // statusIndex 订单状态
    let params = { statusIndex: status };
    if (tCode === 'C') {
      params.typeIndex = 0;
    } else {
      params.typeIndex = orderType === 'S' ? 0 : 1;
    }
    let nameStr = 'HomePage';
    if (GLOBAL.ORDER_KEY == 'CustomerStack') {
      nameStr = 'CrMtManage';
      navigationSeevice.reset('OrderListPage', params, [{ routeName: nameStr }]);
    } else if (GLOBAL.ORDER_KEY == 'OrderStack') {
      nameStr = 'OrderListPage';
      //GLOBAL.TAB_NAVIGATION.popToTop(params);
      navigationSeevice.reset('OrderListPage', params);
    } else if (GLOBAL.ORDER_KEY == 'ReportStack') {
      nameStr = 'ReportIndexPage';
      navigationSeevice.reset('OrderListPage', params, [{ routeName: nameStr }]);
    } else {
      navigationSeevice.reset('OrderListPage', params, [{ routeName: nameStr }]);
    }
  }

  isNeedPaymentDays = (name) => {
    let index = name.indexOf('@@');
    return index > -1
  }

}

module.exports = new OrderCreactService();